#include<iostream>
using namespace std;
#define N 100000
int main(){
  int a[N];
  int n,q;
  cin>>n>>q;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<q;i++){
    int k;
    cin>>k;
    int l=0,r=n-1;
    while(l<r){
      int mid=l+r>>1;
      if(a[mid]>=k) r=mid;
      else l=mid+1;
    }
    if(a[l]!=k){
      cout<<"-1 -1"<<endl;
      continue;
    }else cout<<l<<" ";
    r=n-1;
    while(l<r){
      int mid=l+r+1>>1;
      if(a[mid]<=k)l=mid;
      else r=mid-1;
    }
    cout<<r;
    cout<<endl;
  }
}